package com.etc.service.impl;

import com.etc.dao.VideoOfTypeDao;
import com.etc.pojo.Video;
import com.etc.service.VideoOfTypeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VideoOfTypeServiceImpl implements VideoOfTypeService {

    org.apache.log4j.Logger logger= Logger.getLogger(VideoOfTypeService.class);

    @Autowired
    VideoOfTypeDao dao;

    /**
     * 根据二级分类编号查询视频
     * @param targetIdList
     * @param partIdList
     * @param degreeIdList
     * @param apparatusIdList
     * @param pageNo
     * @param pageSize
     * @return
     */
    @Override
    public PageInfo<Video> getVideoByType(List<Integer> targetIdList,
                                          List<Integer> partIdList,
                                          List<Integer> degreeIdList,
                                          List<Integer> apparatusIdList,
                                          Integer pageNo,
                                          Integer pageSize) {
        logger.debug("这是VideoOfTypeServiceImpl的getVideoByType方法 第一个集合有值吗"+targetIdList);
        logger.debug("这是VideoOfTypeServiceImpl的getVideoByType方法 第二个集合有值吗"+partIdList);
        logger.debug("这是VideoOfTypeServiceImpl的getVideoByType方法 第三个集合有值吗"+degreeIdList);
        logger.debug("这是VideoOfTypeServiceImpl的getVideoByType方法 第四个集合有值吗"+apparatusIdList);


        PageHelper.startPage(pageNo,pageSize);
        List<Video> list = dao.queryVideoByType(targetIdList, partIdList, degreeIdList, apparatusIdList);
        PageInfo<Video> pageInfo = new PageInfo<Video>(list);

        return pageInfo;
    }

    /**
     * 根据视频编号获取视频
     * @param videoId
     * @return
     */
    @Override
    public Video getVideoById(Integer videoId) {
        return dao.queryVideoById(videoId);
    }
}
